// 
//  QuestionFactory.cpp
//  LoginSecurity
//  
//  Created by Ryan Latta on 2008-12-03.
//  Copyright 2008 Ryan Latta. All rights reserved.
// 
#ifndef QUESTIONFACTORY_CPP_RPA9E3PJ
#define QUESTIONFACTORY_CPP_RPA9E3PJ

#include "Security.h"
#endif /* end of include guard: QUESTIONFACTORY_CPP_RPA9E3PJ */

/*
  So I should have thought of a more elegant way to do this, but here is what happens.
  The constructor chooses a random number from 0 to how many question types there are.
  Then it runs through this switch statement to choose the appropriate question.
  Essentially you can add your own question in by simply addjusting the rand() % 2 and
  adding a new case in.
*/
QuestionFactory::QuestionFactory() {  
  srand(time(NULL));
  switch(rand() % 2) {
    case 0:
      question = new MathQuestion();
      break;
    case 1:
      question = new TextQuestion();
      break;
    default:
      //Change this to whatever, but this is my choice.
      question = new MathQuestion();
      break;
  }
}

QuestionFactory::~QuestionFactory() {
  if(question) {
    delete question;
  }
}
